@extends("Admin.layout.layout")
@section("title","话题管理")
@section("con")
<div class="table-responsive">
<div class = "row">
	<div class = "col-md-3 col-md-offset-9">
		<button type="button" class="btn btn-info" onclick = "addtopic()">添加话题</button>
        <form action = "/admin/topic/index" method = "get">
       <input class="form-control input-sm" placeholder="根据话题搜索" aria-controls="dataTables-example" type="text" name = "search" style = "position:absolute;left:-800px;top:0px;">
       <button type="subbit" class="btn btn-success" style = "position:absolute;left:-500px;top:0px;">Success</button>
       </form>
	</div>
</div>
	<script>
		function addtopic(flag)
		{
            if(!flag)
            {
			     location.href = "/admin/topic/add";
            }
            else
            {
                location.href = "/admin/topic/add?fid="+flag;
            }
		}
	</script>
    <table class="table table-striped table-bordered table-hover">
        <thead>
            <tr>
                <th style = "width:50px;">id</th>
                <th style = "width:120px;">话题</th>
                <th style = "width:700px;">话题描述</th>
                <th style = "width:80px;">话题图标</th>
                <th style = "width:80px;">操作</th>
            </tr>
        </thead>
        <tbody>
        <!-- 便利出所有话题 -->
          @foreach($topics as $k=>$v)
            <tr>
                <td>{{$v->id}}</td>
                <td>
                    @if($v->pid == 0)
                    {{$v->topic_name}}<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;<span style = "font-size:20px;color:grey;font-weight:bold" onclick = "addtopic({{$v->id}})">+</span>
                    @else
                    -------|{{$v->topic_name}}
                    @endif
                </td>
                <td>{{$v->topic_summary}}</td>
                <td style = "text-align:center;">@if($v->pid!=0)<?php echo "<img src = '$v->topic_portrait' style = 'height:50px'/>" ?>@endif</td>
                <td><a href = "{{url('/admin/topic/edit',['id'=>$v->id])}}">修改</a>@if(App\Http\Controllers\Admin\TopicController::check($v->id))|<a href = "{{url('/admin/topic/delete',['id'=>$v->id])}}">删除</a>@endif<br /><a href = "{{url('admin/question/mywant',['id'=>$v->id])}}">@if($v->pid!=0)查看问题@endif</a></td>
            </tr>
          @endforeach
          <!-- 便利出所有话题 -->
        </tbody>
    </table>
   {!! $topics->appends([$val])->render() !!}
</div>
@endsection